From b5535b652a18d57015322970cc7310951bfcba4e Mon Sep 17 00:00:00 2001 From: robertl Date: Sat, 8 Mar 2003 03:43:55 +0000 Subject: [PATCH] Allow escaping of comment char. --- gpsbabel/mkstyle.sh | 2 +- gpsbabel/xcsv.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/gpsbabel/mkstyle.sh b/gpsbabel/mkstyle.sh index db643ca7e..cf5650bce 100755 --- a/gpsbabel/mkstyle.sh +++ b/gpsbabel/mkstyle.sh @@ -5,7 +5,7 @@ do [ $A = "README" ] && continue ALIST="{ \"$A\", $A } , $ALIST" echo "static char $A[] = " - sed 's/"/\\"/g;s/\(^.\)/"\1/g;s/\(.$\)/\1\\\n"/g' $i + sed 's/\\/\\\\/;s/"/\\"/g;s/\(^.\)/"\1/g;s/\(.$\)/\1\\\n"/g' $i echo ";" done diff --git a/gpsbabel/xcsv.c b/gpsbabel/xcsv.c index 928122399..24f7df3fc 100644 --- a/gpsbabel/xcsv.c +++ b/gpsbabel/xcsv.c @@ -173,8 +173,14 @@ xcsv_parse_style_line(const char *sbuff) */ /* whack off any comments */ - if ((p = strchr(sbuff, '#')) != NULL) - *p = '\0'; + if ((p = strchr(sbuff, '#')) != NULL) { + if ((p > sbuff) && p[-1] == '\\') { + memmove(p-1, p, strlen(p)); + p[strlen(p)-1] = '\0'; + } else { + *p = '\0'; + } + } if (strlen(sbuff)) { if (ISSTOKEN(sbuff, "FIELD_DELIMITER")) { -- 2.30.2